package com.bf.electroplating.controller;



import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bf.electroplating.pojo.dto.IdDTO;
import com.bf.electroplating.pojo.dto.sysuser.AdminUserDetailDTO;
import com.bf.electroplating.pojo.dto.sysuser.AdminUserPageDTO;
import com.bf.electroplating.pojo.vo.ResultVO;
import com.bf.electroplating.pojo.vo.sysuser.AdminUserVO;
import com.bf.electroplating.pojo.vo.sysuser.UserListVO;
import com.bf.electroplating.service.ISysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * (用户表)SYS_USER 前端控制器
 * </p>
 *
 * @author xxx
 * @since 2024-10-18
 */
@RestController
@RequestMapping ( "/sys-user" )
@Tag ( name = "用户管理", description = "用户管理" )
public class SysUserController {

	@Resource
	private ISysUserService sysUserService;

	// 获取用户列表
	@GetMapping( "/getUserList" )
	@Operation ( summary = "获取用户列表", description = "获取用户列表" )
	public ResultVO <List<UserListVO >> getUserList (  ) {
		return sysUserService.getUserListVO ( );
	}

	@PostMapping ( "/getAdminList" )
	@Operation ( summary = "获取管理员列表", description = "获取管理员列表" )
	public ResultVO < Page < AdminUserVO > > getAdminList ( @RequestBody AdminUserPageDTO dto ) {
		return sysUserService.getAdminList ( dto );
	}

	@PostMapping ( "/saveOrUpdateAdmin" )
	@Operation ( summary = "新增或编辑管理员", description = "新增或编辑管理员" )
	public ResultVO < Object > saveOrUpdateAdmin (@RequestBody AdminUserDetailDTO dto ,HttpServletRequest request) {
		return sysUserService.saveOrUpdateAdmin ( dto ,request);
	}

	@PostMapping ( "/getDetailAdmin" )
	@Operation ( summary = "获取管理员详情", description = "获取管理员详情" )
	public ResultVO < AdminUserDetailDTO > getDetailAdmin ( @RequestBody IdDTO dto ) {
		return sysUserService.getDetailAdmin ( dto );
	}

	@PostMapping ( "/deleteAdmin" )
	@Operation ( summary = "删除管理员", description = "删除管理员" )
	public ResultVO < Object > deleteAdmin ( @RequestBody IdDTO dto ) {
		return sysUserService.deleteAdmin ( dto );
	}

}
